package com.edisoncgh.service;

import com.edisoncgh.dao.ArticleMapper;
import com.edisoncgh.pojo.Article;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl {
    // 设置set接口以调用dao层操作
    @Autowired
    private ArticleMapper articleMapper;

    public void setArticleMapper(ArticleMapper articleMapper) {
        this.articleMapper = articleMapper;
    }

    // 增加一篇文章
    int addArticle(Article article) {
        return articleMapper.addArticle(article);
    }

    // 删除一篇文章
    boolean deleteArticleById(int id) {
        return articleMapper.deleteArticleById(id);
    }

    // 查询一篇文章
    Article findArticleById(int id) {
        return articleMapper.findArticleById(id);
    }

    // 查询所有文章
    List<Article> findAllArticle() {
        return articleMapper.findAllArticle();
    }

    // 更新一篇文章
    boolean updateArticleById(int id) {
        return articleMapper.updateArticleById(id);
    }
}